function check(plr)
	local qq = exports["cmta-db"]:dbGet("SELECT * FROM cmta_users WHERE id=?", getElementData(plr,"player:data").uid)
	realTime=getRealTime()
	local r = realTime.year+1900
	local m = realTime.month+1
	local t = realTime.monthday
	local data=string.format("%04d-%02d-%02d", r, m, t)
	if qq[1].lastlogin <= data then
	local data = getElementData(plr,"player:data")
	data.dailyclicks = 0
	setElementData(plr,"player:data",data)
	exports['cmta-zarabianie']:reset(plr)
    triggerClientEvent(plr,"cmta_aktywujbonus",resourceRoot)
    end
end

addEvent("cmta_bonusdnia_nagroda",true)
addEventHandler("cmta_bonusdnia_nagroda",resourceRoot,function(gift)
if gift == "point" then
	local acoin = math.random(30,60)
	local data = getElementData(client,"player:data")
    local acoin2 = acoin + (acoin*(data.lvl)/100)
	data.points = data.points+acoin2
	setElementData(client,"player:data",data)
	outputChatBox("#00ff00[BONUS DNIA] #808080Otrzymujesz #ff0000"..acoin2.." pkt#ffffff, w tym "..(acoin2-acoin).." pkt bonusu za poziom.",client,255,255,255,true)
elseif gift == "cigarette" then
	local acigarettes = math.random(1,6)
	if acigarettes == 1 then 
		cigarettes = "papierosa" 
	elseif acigarettes == 2 or acigarettes == 3 or acigarettes == 4 then
		cigarettes = "papierosy" 
	else
		cigarettes = "papierosów" 
	end
	exports["cmta-db"]:dbSet("update cmta_inventory set cigarettes=cigarettes+? where uid=?",acigarettes,getElementData(client,"player:data").uid)
	outputChatBox("#00ff00[BONUS DNIA] #808080Otrzymujesz #ff0000"..acigarettes.." "..cigarettes..".",client,255,255,255,true)
elseif gift == "gun" then
	local ammo = math.random(10,60)
	givePedWeapon(client, 22, ammo, true)
	outputChatBox("#00ff00[BONUS DNIA] #808080Otrzymujesz #ff0000 pistolet oraz "..ammo.." amunicji.",client,255,255,255,true)
elseif gift == "vip" then
    local los = math.random(1,3)
    if los > 1 then days = "dni" else days = "dzień" end
    exports["cmta-db"]:dbSet("INSERT cmta_awards (uid,type,amount) VALUES (?,?,?)", getElementData(client,"player:data").uid, "vip",los)
    outputChatBox("#00ff00[BONUS DNIA] #808080Otrzymujesz kupon #ff0000V.I.P na "..los.." "..days..".",client,255,255,255,true)
elseif gift == "car" then
    exports["cmta-db"]:dbSet("INSERT INTO cmta_pojazdy (model,engine,driveType,engineType,ownedPlayer,mileage,parking) VALUES (?,?,?,?,?,0,1)", 424,"1.9T","AWD","Diesel", getElementData(client,"player:uid"))
    outputChatBox("#808080Gracz o nicku #6400FF"..getPlayerName(client):gsub("#%x%x%x%x%x%x","").."#808080 wygrał w bonusie dnia pojazd #ff0000Bf Injection!",root,255,255,255,true)
end
end)

addEvent("cmta_bonusdnia_nalicz",true)
addEventHandler("cmta_bonusdnia_nalicz",resourceRoot,function()
	exports["cmta-db"]:dbSet("UPDATE cmta_users SET lastlogin=NOW() WHERE id=? LIMIT 1",getElementData(client,"player:data").uid)
end)